package rbac.domain.entity;

import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 实体对象基类
 */

public class BaseEntity {
    private Integer id; // 私有的只读属性

    public Integer getId(){ // 公共的访问方法
        return id;
    }

    public BaseEntity(){} // 有参构造⽅法

    public BaseEntity(Integer id){ // ⽆参的构造⽅法
        this.id = id;
    }

    public LocalDateTime createAt;

    public LocalDateTime updateAt;

    public BaseEntity(Integer id, LocalDateTime createAt, LocalDateTime updateAt) {
        this.id = id;
        this.createAt = createAt;
        this.updateAt = updateAt;
    }

    @Override
    public boolean equals(Object o){
        if(this == o) return true;
        if(o == null || getClass() != o.getClass()) return false;
        BaseEntity that = (BaseEntity) o;
        return Objects.equals(getId(), that.getId());
    }

    @Override
    public int hashCode(){
        return Objects.hashCode(getId());
    }

}

